<?php
class Default_Model_SubMenu extends Zend_Db_Table {
	protected $_name    = 'sub_menu';
	protected $_primary = 'id';
	
	// creat item in select box
	public function itemInSelectbox($arrParam = null, $options = null){
		$db = Zend_Registry::get('connectDb');
		//$db = Zend_Db::factory($adapter,$config);
		if($options == null){
			$select = $db->select()
			             ->from('sub_menu AS sm',array('id','name','parents', 'order'))
			             ->order('sm.order ASC');
			$result  = $db->fetchAll($select);
				
		}
	
		/*if($options['task'] == 'admin-edit'){
			$id = $arrParam['id'];
			$select = $db->select()
			             ->from('sub_menu AS sm',array('id','name','parents', 'order'))
			             ->where('id != ?', $id, INTEGER )
			             ->order('sm.order ASC');
				
			$result  = $db->fetchAll($select);
				
		}
	
		$system = new MyZend_System_Recursive($result);
		$result = $system->buildArray(0);
		$tmp = array('id'=>0,'name'=>'Root Menu','level'=>1,'order'=>1,'parents'=>0);
		array_unshift($result,$tmp);*/
	
		//return $result;
		echo '<pre>';
		print_r($result);
		echo '</pre>';
	}
	
}